<?php

namespace App\Listeners;

use App\Events\UserLogin;
use App\Models\UserLoginLog;

class UserLoginListener
{


    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {

    }

    /**
     * Handle the event.
     *
     * @param  UserLogin  $event
     * @return void
     */
    public function handle(UserLogin $event)
    {
        //在登录成功之后返回token之前使用事件进行在用户登录的日志表中插入当前登录用户的数据
        $userlogin = [
            'user_id' => $event->userid,
            'login_ip' => $event->ip,
            'type' => $event->type,
        ];
        UserLoginLog::create($userlogin);
    }
}
